NetworkPacketTrace
NetworkPacketTrace[expr] evaluates expr and returns information on network packets transmitted or received through all network interfaces on your computer during the time of the evaluation, together with the result of the evaluation.
NetworkPacketTrace[expr,service] records only packets associated with the specified network service.
NetworkPacketTrace[expr,port] records only packets associated with the specified port.
NetworkPacketTrace[expr,{port1,port2,…}] records only packets associated with any of the ports porti.
NetworkPacketTrace[expr,spec] records only packets matching the specification spec.
Please visit the official Wolfram Language Reference for more details and examples on core symbols.